<?php
require_once '../sub/init.php';
$currfields = "birthday,loveb,photo_f,photo_s,heigh,pay,refresh_time,dataflag";
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/config_vip.php';
$data_birthday     = $row['birthday'];
$data_loveb        = $row['loveb'];
$data_photo_f      = $row['photo_f'];
$data_photo_s      = $row['photo_s'];
$data_heigh        = $row['heigh'];
$data_pay          = $row['pay'];
$data_refresh_time = $row['refresh_time'];
$data_dataflag     = $row['dataflag'];
if ($data_photo_f  == 1 && $data_photo_s<>'' && !empty($data_heigh) && !empty($data_pay) && $data_birthday<>'0000-00-00'){
	$ifshow = true;
}else{
	$ifshow = false;
}
$IndexPushLoveb = intval(abs($_VIP['push_index']));
if($submitok=="ajax_modupdate"){
	if ($ifshow){
		if ($IndexPushLoveb > $data_loveb) {
			$jumpurl=HOST.'/m/my_refresh.php';
			json_exit(array('flag'=>'noloveb','jumpurl'=>$jumpurl,'msg'=>'账户余额不足 <i class=\'ico zeaicolor\'>&#xe618;</i> <font class=\'zeaicolor\'>'.$IndexPushLoveb.'</font> '.$_ZEAI['loveB']));
		} else {
			if($IndexPushLoveb>0){
				$SQL=",loveb=loveb-$IndexPushLoveb";
				$db->AddLovebRmbList($cook_uid,'刷新靠前',-$IndexPushLoveb,'loveb',10);
			}else{
				$SQL= "";
			}
			$db->query("UPDATE ".__TBL_USER__." SET refresh_time=".ADDTIME.$SQL." WHERE id=".$cook_uid);
			json_exit(array('flag'=>1,'msg'=>'恭喜您刷新成功！'));
		}
	}else{
		if ($data_photo_f == 0 || empty($data_photo_s)){
			json_exit(array('flag'=>0,'msg'=>'请先上传头像哦'));
		}else{
			json_exit(array('flag'=>0,'msg'=>'请完善基本资料'));
		}
	}
}
$nodatatips = "<div class='nodatatips'><i class='ico'>&#xe659;</i>暂时木有会员</div>";
$t = (ifint($t,'1-3','1'))?$t:1;
$mc = $db->COUNT(__TBL_USER__,"birthday<>'0000-00-00' AND heigh>0 AND flag=1 AND dataflag=1 AND kind<>4 AND refresh_time>".$data_refresh_time);
$mc = $mc+1;

if($IndexPushLoveb>0){
	$okstr='刷新靠前一次需花费 <i class="ico zeaicolor">&#xe618;</i> <font class="zeaicolor">'.$IndexPushLoveb.'</font> '.$_ZEAI['loveB'];
	$dh='，';
}
?>
<!doctype html><html><head><meta charset="utf-8">
<title>我的-<?php echo $_ZEAI['siteName'];?></title>
<?php echo HEADMETA; ?>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<link href="<?php echo RES;?>m/css/my_refresh.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/my_refresh.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<style>
.tabmenu a.ed,.my_refresh .mpi section div{color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.tabmenu a.ed:after{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
header.bgcolor,.my_mateshow_btm a{background-color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.my_mateshow_btm a{box-shadow:0 3px 8px rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.4)}
.my_refresh .mpi section div:last-child:before{content:'当前<?php echo $_ZEAI['loveB']; ?>'}
<?php
if ($_ZEAI['m_mb']==2){
	echo '.TRnav_btn i{color:'.$_ZEAI['mob_mbcolor'].'}';
	$mini_class='top_mini4';
}else{
	$mini_class='top_mini4 zeaibg bgcolor yunbox';
}
?>

</style>
<script>var okstr='确定提交么？<?php echo $okstr;?>';</script>
</head><body>
<?php
//$mini_class='top_mini4 bgcolor yunbox';
$mini_title='刷新靠前';
require_once ZEAI.'m/top_mini.php';?>
<div class="my_refresh">
	<?php if (!$ifshow){ ?>
    <div class="mpi">
    	<i class="ico sorrympi">&#xe659;</i>
        <h3>您无法使用此功能</h3><br>
        <font class="S14 C999 lineH150">1．头像未上传<br>2．资料不完善<br>（例如：生日、身高、学历，职业等） <br><br>
		<a class="btn size2 yuan zeaibg" href="my_info.php?jumpurl=my_refresh.php"><i class="ico">&#xe610;</i> 我要完善资料</a>　<a class="btn size2 yuan zeaibg" href="my_info.php?jumpurl=my_refresh.php"><i class="ico">&#xe609;</i> 我要上传头像</a></font><br><br>
    </div>
	<?php }else{?>
        <div class="mpi">
            <section>
                <div><font>第</font><span id="my_push_idxmc"><?php echo $mc; ?></span><font>名</font></div>
                <div><span id="my_push_idxlovb"><?php echo $data_loveb; ?></span><font>个</font></div>
            </section>
            <div class="clear"></div>
            <div class="Clist">
                <div>1．<?php echo $okstr.$dh;?>直到其他会员将你顶下去，否则你将永远排前面</div>
                <div>2．请不要连续提交<?php if($IndexPushLoveb>0){echo '，提交一次扣除一次';}?>，推荐两天刷新排名一次</div>
            </div>
        </div>
    <?php }?>
	<div class="mpi">
        <div class="linebox"><div class="line W50"></div><div class="title BAI">会员排名TOP10</div></div><br>
        <div class="tabmenu tabmenu3">
            <a href="my_refresh.php?t=1"<?php echo ($t == 1)?' class="ed"':'';?>>全部</a>
            <a href="my_refresh.php?t=2"<?php echo ($t == 2)?' class="ed"':'';?>>男生</a>
            <a href="my_refresh.php?t=3"<?php echo ($t == 3)?' class="ed"':'';?>>女生</a>
        </div>
        <dl class="tbody"><dt>名次</dt><dd>冒泡人</dd></dl>
        <div class="my_refresh_list">
        <?php 
		if($t == 2){
            $sql = " AND sex=1";
        }elseif($t == 3){
            $sql = " AND sex=2";
        }
        $rt=$db->query("SELECT id,sex,grade,nickname,photo_s,photo_f FROM ".__TBL_USER__." WHERE birthday<>'0000-00-00' AND heigh>0 AND flag=1 AND dataflag=1 AND kind<>4 ".$sql." ORDER BY refresh_time DESC LIMIT 10");
        $total = $db->num_rows($rt);
        if ($total > 0) {
            for($i=1;$i<=$total;$i++) {
			$rows = $db->fetch_array($rt,"name");
			if(!$rows)break;
			$uid           = $rows['id'];
			$sex           = $rows['sex'];
			$grade         = $rows['grade'];
			$nickname      = dataIO($rows['nickname'],'out');
			$nickname      = urldecode($nickname);
			$photo_s       = $rows['photo_s'];
			$photo_f       = $rows['photo_f'];
			$birthday      = $rows['birthday'];
			$photo_s_url   = (!empty($photo_s) && $photo_f==1)?UP.smb($photo_s,'m'):RES.'photo_m'.$sex.'.png';
			$ifown = ($uid == $cook_uid)?' <font>(我)</font>':'';
			if ($uid == $cook_uid){
				$ifown = ' <font>(我)</font>';
				$ifed  = ' class="my"';
			}else{
				$ifown = '';$ifed  = '';
			}
			?>
        <dl<?php echo $ifed; ?>><dt>第<font><?php echo $i; ?></font>名</dt><dd><a uid='<?php echo $uid;?>'></i><?php echo uicon($sex.$grade).$nickname; ?><?php echo $ifown; ?></a></dd></dl>
        <?php }}else{echo $nodatatips ;}?>
        </div>
   </div>
</div>
<div class="my_mateshow_btm"><a id="my_refresh_sbmtbtn"><i class="ico">&#xe632;</i> 立即刷新靠前</a></div>
<?php require_once ZEAI.'m/TRnav.php';?>
</body></html>